/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package managedbean;

import javax.ejb.EJB;
import javax.enterprise.context.SessionScoped;
import javax.faces.bean.ManagedBean;
import javax.faces.event.ActionEvent;
import javax.mail.MessagingException;
import session.stateful.EmailSessionBean;
import session.stateless.TimerSessionBean;

/**
 *
 * @author HenryHieuPham
 */
@ManagedBean(name = "timerManagerBean")
@SessionScoped
public class TimerManagerBean {

    @EJB
    TimerSessionBean timerSessionBean;
    @EJB
    EmailSessionBean eMailSessionBean;


    /** Creates a new instance of TimerManagerBean */
    public TimerManagerBean() {
    }

    public void createTimer(ActionEvent event) throws MessagingException {
        System.out.println("1");
        timerSessionBean.createTimers();
        System.out.println("2");
    }

    public void sendEmailWithAttachement(ActionEvent event) throws MessagingException {
        eMailSessionBean.setPassword("emsongtronguocao");
        eMailSessionBean.setUser("is3102team32");
        System.out.println("A");
        String subject = "Reset Password";
        String standardmsg = "Test attachement";
        String recipient = "pttrunghieu@gmail.com";
        String from = "is3102team32@gmail.com";
        System.out.println("7");
        eMailSessionBean.sendMailAttachment(recipient, subject, standardmsg, from, "C:\\Users\\HenryHieuPham\\Desktop\\IS3102_class_diagram.png");
        System.out.println("8");
    }
    
    
}



